package com.usian.residentialquarters.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.usian.commom.pojo.ResidentialQuarters;
import com.usian.commom.vo.ResultCommonVo;
import com.usian.residentialquarters.mapper.ResidentialQuartersMapper;
import com.usian.residentialquarters.service.ResidentialQuartersService;
import org.springframework.stereotype.Service;

/**
 * @TODO:
 * @Author:baimu
 * @Date:2023 11 30 14 01
 **/

@Service
public class ResidentialQuartersServiceImpl extends ServiceImpl<ResidentialQuartersMapper, ResidentialQuarters>
implements ResidentialQuartersService {
    @Override
    public ResultCommonVo findResidentialQuartersPage(ResidentialQuarters residentialQuarters,Integer page,Integer size) {
        QueryWrapper<ResidentialQuarters> residentialQuartersQueryWrapper = new QueryWrapper<>();

       if(residentialQuarters.getName()!=""&&residentialQuarters.getName()!=null){
           residentialQuartersQueryWrapper.lambda().eq(StringUtils.isNotColumnName(residentialQuarters.getName())
                   ,ResidentialQuarters::getName
                   ,residentialQuarters.getName());

       }

        Page<ResidentialQuarters> residentialQuartersPage = new Page<>(page, size);


        Page<ResidentialQuarters> residentialQuartersPage1 =
                this.baseMapper.selectPage(residentialQuartersPage, residentialQuartersQueryWrapper);



        return ResultCommonVo.success(residentialQuartersPage1);
    }
}
